package viewmodel;

import java.util.ArrayList;
import java.util.List;

import admin.dao.UserDAO;

import model.User;

public class UserDataModel {
	private List<User> allUser = new ArrayList<User>();
	
	public UserDataModel() {
		updateAllUser();
	}

	public List<User> getAllUser() {
		return allUser;
	}
	
	public void updateAllUser() {
		this.allUser = UserDAO.getAllUser();
	}

	public void removeUser(User selUser) {
		allUser.remove(selUser);
	}
	
	public static List<UserEditStatus> convertUserToEditData(List<User> listUser) {
		ArrayList<UserEditStatus> result = new ArrayList<UserEditStatus>();
		
		for (User user : listUser) {
			UserEditStatus userEdit = new UserEditStatus(user, false);
			userEdit.setLevel(new UserLevelModel(user.getLever()));
			result.add(userEdit);
			
		}
		return result;
	}
	
	public List<UserEditStatus> convertUserToEditData() {
		return UserDataModel.convertUserToEditData(allUser);
	}
}
